/* 
 * Copyright 2014 Josef Hertl.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package caetus.pkcs11.session;

/**
 * Controls the options passed to the application from the command line.
 *
 * @author Josef Hertl
 */
public class CommandLineOptions {

    private boolean prepareModelChecking = false;
    private boolean performModelChecking = false;
    private boolean showFullResults = false;
    private String nssConfigFile;
    private String filePath;
    private boolean checkFilePath;
    private char[] pin;
    private int slot = 1;
    private boolean inform = true;
    private boolean noPrintCmd = false;
    private boolean onlyTestStandard = false;

    public CommandLineOptions(String[] args) {
        for (int i = 0; i < args.length; i++) {
            if ("-nssConfig".equals(args[i])) {
                nssConfigFile = args[i + 1];
            }
            if ("-library".equals(args[i])) {
                filePath = args[i + 1];
            }
            if ("-PIN".equals(args[i])) {
                pin = args[i + 1].toCharArray();
            }
            if ("-slot".equals(args[i])) {
                try {
                    slot = Integer.parseInt(args[i + 1]);
                } catch (NumberFormatException ex) {
                    System.err.println("Argument slot must be an integer! Defaulting to slot = 1.");
                    slot = 1;
                }
            }
            if ("-checkModel".equals(args[i])) {
                performModelChecking = true;
            }
            if ("-prepareModel".equals(args[i])) {
                prepareModelChecking = true;
            }
            if ("-showFullResults".equals(args[i])) {
                showFullResults = true;
            }
            if ("-noPrintCmd".equals(args[i])) {
                noPrintCmd = true;
            }
            if ("-checkFile".equals(args[i])) {
                checkFilePath = true;
            }
            if ("-onlyTestStandard".equals(args[i])) {
                onlyTestStandard = true;
            }
            if ("-noInform".equals(args[i])) {
                inform = false;
            }
        }
    }

    public boolean isPrepareModelChecking() {
        return prepareModelChecking;
    }

    public boolean isPerformModelChecking() {
        return performModelChecking;
    }

    public boolean isShowFullResults() {
        return showFullResults;
    }

    public String getNssConfigFile() {
        return nssConfigFile;
    }

    public String getFilePath() {
        return filePath;
    }

    public char[] getPin() {
        return pin;
    }

    public int getSlot() {
        return slot;
    }

    public boolean isInform() {
        return inform;
    }

    public boolean isNoPrintCmd() {
        return noPrintCmd;
    }

    public boolean isOnlyTestStandard() {
        return onlyTestStandard;
    }

    public boolean getCheckFilePath() {
        return checkFilePath;
    }
}
